package com.dyc.caradvertisting.ui.fmt.bind;

import com.dyc.caradvertisting.bean.req.RequestBean;
import com.dyc.caradvertisting.constants.Constant;
import com.dyc.caradvertisting.ui.fmt.register.RegisterContract;
import com.njh.tools.common.ToastUtils;

import java.util.Map;

import rx.Observable;
import rx.Observer;


/**
 * Created by niejiahuan on 2016/5/31.
 */
public class BindSetPresenter extends BindSerContract.Presenter {


    @Override
    public Observable getDate(Map<String, String> params) {
        RequestBean requestBean=new RequestBean(Constant.REQ_SET_LIST,params.get("uid"));
        return mModel.reqBindSetList(requestBean.getAct()+"",
                requestBean.getAct()+"",
                requestBean.getParam(),
                requestBean.getSign(),
                requestBean.getStrtime()+"");
    }

    @Override
    public void onStart() {

    }
    @Override
    public void reqBindSet(String param) {
        RequestBean requestBean=new RequestBean(Constant.REQ_BING_SET,param);
         mModel.reqBindSetList(requestBean.getAct()+"",
                requestBean.getAct()+"",
                requestBean.getParam(),
                requestBean.getSign(),
                requestBean.getStrtime()+"").subscribe(new Observer() {
             @Override
             public void onCompleted() {

             }

             @Override
             public void onError(Throwable e) {
              mView.showError(e);
             }

             @Override
             public void onNext(Object o) {
              ToastUtils.showShort(mContext,"绑定成功!");
                 mView.finish();
             }
         });
    }

    @Override
    public void reqRemoveBindSet(String param) {
        RequestBean requestBean=new RequestBean(Constant.REQ_OPPEN_BIND_SET,param);
        mModel.reqBindSetList(requestBean.getAct()+"",
                requestBean.getAct()+"",
                requestBean.getParam(),
                requestBean.getSign(),
                requestBean.getStrtime()+"").subscribe(new Observer() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(Object o) {

            }
        });
    }

    @Override
    public void reqBindSetDetails(String param) {
        RequestBean requestBean=new RequestBean(Constant.REQ_SET_D,param);
        mModel.reqBindSetList(requestBean.getAct()+"",
                requestBean.getAct()+"",
                requestBean.getParam(),
                requestBean.getSign(),
                requestBean.getStrtime()+"").subscribe(new Observer() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(Object o) {

            }
        });
    }
}
